<?php

namespace App\Http\Controllers\Admin;

use App\Setting;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class SettingController extends Controller
{
    public function index(){
        $setting=Setting::all()->pluck('value','name');
        return view('admin.setting.index',compact('setting'));
    }
    public function store(Request $request){
        foreach ($request->all() as $k=>$v){
            $setting=Setting::where('name',$k)->first();
            if($setting){
            $setting->value=$v;
            $setting->save();
            }
        }
        return redirect()->back()->with(
            $this->success()
        );
    }
}
